﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Coding4Fun.Cannon.Web.Common
{
	public struct Result
	{
		public Dictionary<string, object> Data
		{
			get { return _data ?? (_data = new Dictionary<string, object>()); }
			set { _data = value; }
		}
		private Dictionary<string, object> _data;

		public string Command { get; set; }
		public bool HasExecuted { get; set; }
		public string QueryString { get; set; }
		public DateTime Time { get; set; }
		
		public override string ToString()
		{
			StringBuilder sb = new StringBuilder("<Results>");

			sb.AppendFormat("<Command>{0}</Command>", Command);
			sb.AppendFormat("<HasExecuted>{0}</HasExecuted>", HasExecuted);

			foreach (var value in Data)
				sb.AppendFormat("<{0}>{1}</{0}>", value.Key, value.Value);

			sb.Append("</Results>");
			return sb.ToString();
		}
	}
}
